VERSION 5.00
Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "MSFLXGRD.OCX"
Begin VB.Form History 
   Caption         =   "History Record"
   ClientHeight    =   8100
   ClientLeft      =   60
   ClientTop       =   450
   ClientWidth     =   11550
   LinkTopic       =   "Form1"
   MDIChild        =   -1  'True
   ScaleHeight     =   8100
   ScaleWidth      =   11550
   WindowState     =   2  'Maximized
   Begin MSFlexGridLib.MSFlexGrid gridHistory 
      Height          =   8175
      Left            =   240
      TabIndex        =   0
      Top             =   240
      Width           =   19815
      _ExtentX        =   34951
      _ExtentY        =   14420
      _Version        =   393216
      Rows            =   500
      Cols            =   11
      FixedCols       =   0
      WordWrap        =   -1  'True
      HighLight       =   2
      GridLines       =   2
      GridLinesFixed  =   1
      AllowUserResizing=   3
      Appearance      =   0
   End
   Begin VB.Label Comment 
      Height          =   2175
      Left            =   240
      TabIndex        =   1
      Top             =   8640
      Width           =   11535
   End
End
Attribute VB_Name = "History"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset

Private Sub Form_Load()
    Dim sql As String
    frmSplash.Show
    DoEvents
    Call Cn2Oversea(cn)
    sql = "select * from org_details order by temp_userid desc limit 0, 499"
    rs.Source = sql
    rs.Open sql, cn, adOpenStatic, adLockBatchOptimistic
    init_head
    Call LoadData(rs)
    show_comment
    Unload frmSplash
End Sub
Private Sub show_comment()
    Comment.ForeColor = vbRed
    Comment.Caption = "City ID-> 1:ACT 2:NSW 3:NT 4:QLD 5:SA 6:TAS 7:VIC 8:WA 9:Australia" & _
    vbCrLf & "All data can be edited if you double click the ID"
End Sub
Private Sub init_head()
    With gridHistory
        .TextMatrix(0, 0) = "ID"
        .ColWidth(0) = .Width * 0.04
        .TextMatrix(0, 1) = "Name"
        .ColWidth(1) = .Width * 0.1
        .TextMatrix(0, 2) = "Address"
        .ColWidth(2) = .Width * 0.15
        .TextMatrix(0, 3) = "Fax"
        .ColWidth(3) = .Width * 0.1
        .TextMatrix(0, 4) = "Website"
        .ColWidth(4) = .Width * 0.15
        .TextMatrix(0, 5) = "Email"
        .ColWidth(5) = .Width * 0.1
        .TextMatrix(0, 6) = "Phone"
        .ColWidth(6) = .Width * 0.1
        .TextMatrix(0, 7) = "IM"
        .ColWidth(7) = .Width * 0.02
        .TextMatrix(0, 8) = "City"
        .ColWidth(8) = .Width * 0.03
        .TextMatrix(0, 9) = "Slang"
        .ColWidth(9) = .Width * 0.1
        .TextMatrix(0, 10) = "Introduction"
        .ColWidth(10) = .Width * 0.2
        '.SelectionMode = flexSelectionByRow
    End With
End Sub

Private Function GetValue(ByRef value)
    If IsNull(value) Then
       value = ""
    End If
    
    GetValue = value
End Function

Private Sub LoadData(ByVal rs As ADODB.Recordset)
    Dim iX, iY As Integer
    iX = 0
    iY = 1
    rs.MoveFirst
    While Not rs.EOF
        DoEvents
        iX = 0
        With gridHistory
            .TextMatrix(iY, iX) = str(rs.Fields(1).value)
            iX = iX + 1
            .TextMatrix(iY, iX) = rs.Fields(15).value
            iX = iX + 1
            .TextMatrix(iY, iX) = rs.Fields(2).value
            iX = iX + 1
            .TextMatrix(iY, iX) = rs.Fields(3).value
            iX = iX + 1
            .TextMatrix(iY, iX) = rs.Fields(4).value
            iX = iX + 1
            .TextMatrix(iY, iX) = rs.Fields(11).value
            iX = iX + 1
            .TextMatrix(iY, iX) = rs.Fields(12).value
            iX = iX + 1
            .TextMatrix(iY, iX) = GetValue(rs.Fields(13).value)
            iX = iX + 1
            .TextMatrix(iY, iX) = rs.Fields(23).value
            iX = iX + 1
            .TextMatrix(iY, iX) = GetValue(rs.Fields(8).value)
            iX = iX + 1
            .TextMatrix(iY, iX) = GetValue(rs.Fields(9).value)
            iX = iX + 1
        End With
        iY = iY + 1
        rs.MoveNext
    Wend
End Sub

Private Sub Form_Unload(Cancel As Integer)
    cn.Close
End Sub



Private Sub gridHistory_Click()
    With gridHistory
        .SelectionMode = flexSelectionByRow
    End With
End Sub

Private Sub gridHistory_DblClick()
    With gridHistory
        If .Col = 0 Then
            CustomerType = SEARCH_HISTORY
            Unload customer
            
            customer.temp_userid = .TextMatrix(.Row, .Col)
            customer.Show
            Me.Hide
        End If
    End With
End Sub

